package com.example.growthmuseum.museum;

import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.example.growthmuseum.R;
import com.example.growthmuseum.data.model.Goods;
import com.jude.easyrecyclerview.adapter.BaseViewHolder;

import de.hdodenhof.circleimageview.CircleImageView;

/**
 * Created by Roman on 2016/10/30.
 */
public class MuseumViewHolder extends BaseViewHolder<Goods> {

    private ImageView goodsPicImg;
    private TextView goodsNameText;
    private TextView goodsInfoText;
    private CircleImageView userPicCimg;


    public MuseumViewHolder(ViewGroup parent) {
        super(parent, R.layout.item_museum);
        goodsNameText = $(R.id.goods_name_text);
        goodsPicImg = $(R.id.goods_pic_img);
        goodsInfoText = $(R.id.goods_info_text);
        userPicCimg = $(R.id.user_pic_cimg);
    }

    @Override
    public void setData(final Goods goods) {
        goodsNameText.setText(goods.getGoodsName());
        goodsInfoText.setText(goods.getGoodsInfo());
        Glide.with(getContext())
                .load(goods.getGoodsPic())
                .centerCrop()
                .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                .into(goodsPicImg);
        if (goods.getUserId() != 1) {
            userPicCimg.setImageResource(R.drawable.images2);
        }
    }

}
